Hệ thống quản lý ISP trong PHP
1 <?php
2 // Start from getting the hader which contains some settings we need
3 require_once 'includes/header.php';
4
5 // Redirect visitor to the login page if he is trying to access
6 // this page without being logged in
7 if (!isset($_SESSION['admin_session']) )
8 {
9 $commons->redirectTo(SITE_PATH.'login.php');
10 }
11 ?>
12 <?php
13 require_once "includes/classes/admin-class.php";
14 $admins = new Admins($dbh);
15 ?>
16
17 <div class="dashboard">
18
19 <div class="col-md-12 col-sm-12" id="employee_table">
20 <div class="panel panel-default">
21 <div class="panel-heading">
22 <h4>Customers</h4>
23 </div>
24 <div class="panel-body">
25 <div class="col-md-6">
26 <button type="button" name="add" id="add" class="btn btn-info" data-toggle="modal" data-target="#add_data_Modal">Add New Customer</button>
27 <button onclick="packages()" class="btn btn-info">Packages</button>
28 </div>
29 <div class="col-md-6">
30 <form class="form-inline pull-right">
31 <div class="form-group">
32 <label class="sr-only" for="search">Search for</label>
33 <div class="input-group">
34 <div class="input-group-addon"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></div>
35 <input type="text" class="form-control" id="search" placeholder="Type a name">
36 <div class="input-group-addon"></div>
37 </div>
38 </div>
39 <!-- <button type="submit" class="btn btn-info">Search</button> -->
40 </form>
41 </div>
42 <?php if ( isset($_SESSION['errors']) ) {?>
43 <div class="pannel panel-warning">
44 <?php foreach ($_SESSION['errors'] as $error):?>
45 <li><?= $error ?></li>
46 <?php endforeach ?>
47 </div>
48 <?php session::destroy('errors');
49 } ?>
50 </div>
51 <table class="table table-striped" id="grid-basic">
52 <thead class="thead-inverse">
53 <tr class="info">
54 <th>ID </th>
55 <th>Action</th>
56 <th>Name</th>
57 <th>NID</th>
58 <th>ADDRESS</th>
59 <th>Package</th>
60 <th>IP </th>
61 <th>Email </th>
62 <th>Contact</th>
63 <th>Type</th>
64 </tr>
65 </thead>
66 <tbody>
67 </tbody>
68 </table>
69 </div>
70 </div>
71 <!-- invisible content -->
72 <!-- Insert modal for users -->
73 <div id="add_data_Modal" class="modal fade">
74 <div class="modal-dialog">
75 <div class="modal-content">
76 <div class="modal-header">
77 <button type="button" class="close" data-dismiss="modal">×</button>
78 <h4>Insert Data</h4>
79 </div>
80 <form action="" method="POST" id="insert_form">
81 <div class="modal-body">
82 <!-- form content -->
83 <div class="form-group">
84 <label for="full_name">Full Name</label>
85 <input type="full_name" class="form-control" id="full_name" name="full_name" aria-describedby="emailHelp" placeholder="Full Name" required>
86 </div>
87 <div class="form-group">
88 <label for="nid">NID</label>
89 <input type="text" class="form-control" id="nis" name="nid" placeholder="NID" required>
90 </div>
91 <div class="form-group">
92 <label for="address">Address</label>
93 <input type="textarea" class="form-control" id="address" name="address" placeholder="Address" required>
94 </div>
95 <div class="form-group">
96 <label for="email">Email</label>
97 <input type="text" class="form-control" id="email" name="email" placeholder="Email Address" required>
98 </div>
99 <div class="form-group">
100 <label for="conn_location">Connection Location</label>
101 <input type="textarea" class="form-control" id="conn_location" name="conn_location" placeholder="Connection location">
102 </div>
103 <div class="form-group">
104 <label for="package">Select Package</label>
105 <select class="form-control form-control-sm" name="package" id="package">
106 <?php
107 $packages = $admins->getPackages();
108 if (isset($packages) && sizeof($packages) > 0){
109 foreach ($packages as $package) { ?>
110 <option value='<?=$package->id?>'><?=$package->name?></option>
111 <?php }} ?>
112 </select>
113 </div>
114 <div class="form-group">
115 <label for="ip_address">IP Address</label>
116 <input type="text" class="form-control" id="ip_address" name="ip_address" placeholder="IP Address">
117 </div>
118 <div class="form-group">
119 <label for="conn_type">Connection Type</label>
120 <input type="text" class="form-control" id="conn_type" name="conn_type" placeholder="Connection Type">
121 </div>
122
123 <div class="form-group">
124 <label for="contact">Contact</label>
125 <input type="tel" class="form-control" id="contact" name="contact" placeholder="Contact" required>
126 </div>
127 </div>
128 <div class="modal-footer">
129 <button type="submit" class="btn btn-primary">Submit</button>
130 <a href="#" class="btn btn-warning" data-dismiss="modal">Cancel</a>
131 </div>
132 </form>
133 </div>
134 </div>
135 </div>
136
137 <?php
138 include 'includes/footer.php';
139 ?>
140 <script type="text/javascript">
141 $('#insert_form').on('submit',function(event){
142 event.preventDefault();
143 $.ajax({
144 url: "customers_approve.php?p=add",
145 method:"POST",
146 data:$('#insert_form').serialize(),
147 success: function (data) {
148 $('#insert_form')[0].reset();
149 $('#add_data_Modal').modal('hide');
150 viewData();
151 }
152 });
153 });
154 function viewData() {
155 $.ajax({
156 method: "GET",
157 url:"customers_approve.php",
158 success: function(data){
159 $('tbody').html(data);
160 }
161 });
162 }
163 function delData(del_id){
164 var id = del_id;
165 $.ajax({
166 method:"POST",
167 url: "customers_approve.php?p=del",
168 data: "id="+id,
169 success: function (data){
170 viewData();
171 }
172 });
173 }
174 function updateData(str){
175 var id = str;
176 var full_name = $('#fnm-'+str).val();
177 var nid = $('#nid-'+str).val();
178 var address = $('#ad-'+str).val();
179 var package = $('#pk-'+str).val();
180 var conn_location = $('#conn_loc-'+str).val();
181 var email = $('#em-'+str).val();
182 var ip_address = $('#ip-'+str).val();
183 var conn_type = $('#ct-'+str).val();
184 var contact = $('#con-'+str).val();
185 $.ajax({
186 method:"POST",
187 url: "customers_approve.php?p=edit",
188 data: "full_name="+full_name+"&nid="+nid+"&address="+address+"&conn_location="+conn_location+"&email="+email+"&package="+package+"&ip_address="+ip_address+"&conn_type="+conn_type+"&contact="+contact+"&id="+id,
189 success: function (data){
190 console.log(data);
191 viewData();
192 }
193 });
194 }
195 window.onload = viewData();
196 </script>
197 <script type="text/javascript">
198 $(function() {
199 grid = $('#grid-basic');
200
201 // handle search fields of members key up event
202 $('#search').keyup(function(e) {
203 text = $(this).val(); // grab search term
204
205 if(text.length > 1) {
206 grid.find('tr:has(td)').hide(); // hide data rows, leave header row showing
207
208 // iterate through all grid rows
209 grid.find('tr').each(function(i) {
210 // check to see if search term matches Name column
211 if($(this).find('.search').text().toUpperCase().match(text.toUpperCase()))
212 $(this).show(); // show matching row
213 });
214 }
215 else
216 grid.find('tr').show(); // if no matching name is found, show all rows
217 });
218
219 });
220
221
222 function packages() {
223 let left = (screen.width/2)-(600/2);
224 let top = (screen.height/2)-(800/2);
225 let params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=600,height=800,left=${left},top=${top}`;
226 open('packages.php', 'Packages', params)
227 }
228 </script>